﻿using Newtonsoft.Json;
using Stock.Client.Utils;
using Stock.Model.WX;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Stock.Client.Service
{
      public class WXService
      {


            public static bool SendMessage(string centent = "")
            {
                  //string url = string.Format(ConfigurationManager.AppSettings["SendMessage"].ToString(), RedisService.GetToken().access_token);
                  //SendTextMessage sendTextMessage = new SendTextMessage()
                  //{
                  //      msgtype = "text",
                  //      touser =ConfigurationManager.AppSettings["OpenID"].ToString(),
                  //      text = new TestMessageContent() { content = centent }
                  //};
                  //WXResult wXResult = JsonConvert.DeserializeObject<WXResult>(HttpUtils.PostAsync(JsonConvert.SerializeObject(sendTextMessage), url, "").Result);
                  //if (wXResult.errcode == "0")//成功
                  //{
                  //      return true;
                  //}
                  return false;
            }

            public static bool SendMessage(List<string> centents)
            {
                  string centent = string.Empty;
                  centents.ForEach(o => centent += o + "。\r\n");
                  return SendMessage(centent);
            }
      }
}
